package com.eastfair.pay.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.eastfair.annotation.model.EchoVO;
import com.eastfair.core.base.entity.Entity;
import com.eastfair.pay.enums.InvoiceBusinessTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

import javax.validation.constraints.Size;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;
import static com.eastfair.core.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

/**
 * <p>
 * 实体类
 * 发票
 * </p>
 *
 * @author gj
 * @since 2022-06-21
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("pay_invoice")
@ApiModel(value = "Invoice", description = "发票")
@AllArgsConstructor
public class Invoice extends Entity<Long> implements EchoVO {

    private static final long serialVersionUID = 1L;
    @TableField(exist = false)
    private Map<String, Object> echoMap = new HashMap<>();
    /**
     * 是否启用：1是；0否
     */
    @ApiModelProperty(value = "是否启用：1是；0否")
    @TableField(value = "is_enabled")
    @Excel(name = "是否启用：1是；0否")
    private Integer isEnabled;

    /**
     * 是否删除：1是；0否
     */
    @ApiModelProperty(value = "是否删除：1是；0否")
    @TableField(value = "is_deleted")
    @Excel(name = "是否删除：1是；0否")
    private Integer isDeleted;

    /**
     * 项目id
     */
    @ApiModelProperty(value = "项目id")
    @TableField(value = "project_id")
    @Excel(name = "项目id")
    private Long projectId;

    /**
     * 子系统id
     */
    @ApiModelProperty(value = "子系统id")
    @TableField(value = "subsystem_id")
    @Excel(name = "子系统id")
    private Long subsystemId;

    /**
     * 租户id
     */
    @ApiModelProperty(value = "租户id")
    @TableField(value = "tenant_id")
    @Excel(name = "租户id")
    private Long tenantId;

    /**
     * 合同id,结算单id
     */
    @ApiModelProperty(value = "合同id,结算单id")
    @TableField(value = "business_id")
    @Excel(name = "合同id,结算单id")
    private Long businessId;

    /**
     * 开票来源类型#{H:合同;J:结算单;}
     */
    @ApiModelProperty(value = "开票来源类型#{H:合同;J:结算单;}")
    @TableField(value = "business_type")
    @Excel(name = "开票来源类型#{H:合同;J:结算单;}", replace = {"合同_H", "结算单_J", "_null"})
    private InvoiceBusinessTypeEnum businessType;

    /**
     * 发票类型
     */
    @ApiModelProperty(value = "发票类型")
    @Size(max = 255, message = "发票类型长度不能超过255")
    @TableField(value = "invoice_type", condition = LIKE)
    @Excel(name = "发票类型")
    private String invoiceType;

    /**
     * 发票代码
     */
    @ApiModelProperty(value = "发票代码")
    @Size(max = 255, message = "发票代码长度不能超过255")
    @TableField(value = "invoice_code", condition = LIKE)
    @Excel(name = "发票代码")
    private String invoiceCode;

    /**
     * 发票号码
     */
    @ApiModelProperty(value = "发票号码")
    @Size(max = 255, message = "发票号码长度不能超过255")
    @TableField(value = "invoice_num", condition = LIKE)
    @Excel(name = "发票号码")
    private String invoiceNum;

    /**
     * 发票金额
     */
    @ApiModelProperty(value = "发票金额")
    @Size(max = 255, message = "发票金额长度不能超过255")
    @TableField(value = "invoice_amount", condition = LIKE)
    @Excel(name = "发票金额")
    private BigDecimal invoiceAmount;

    /**
     * 开票时间
     */
    @ApiModelProperty(value = "开票时间")
    @TableField(value = "invoicing_time")
    @Excel(name = "开票时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime invoicingTime;

    /**
     * 开票状态
     */
    @ApiModelProperty(value = "开票状态 ")
    @TableField(value = "invoice_state")
    @Excel(name = "开票状态")
    private String invoiceState;

    /**
     * 费用类型
     */
    @ApiModelProperty(value = "费用类型")
    @Size(max = 255, message = "费用类型长度不能超过255")
    @TableField(value = "cost_type", condition = LIKE)
    @Excel(name = "费用类型")
    private String costType;

    /**
     * 经手人id
     */
    @ApiModelProperty(value = "经手人id")
    @TableField(value = "applicant_id")
    @Excel(name = "经手人id")
    private Long applicantId;

    /**
     * 经手人名称登录人所在部门所有人（默认当前登录人）
     */
    @ApiModelProperty(value = "经手人名称登录人所在部门所有人（默认当前登录人）")
    @Size(max = 255, message = "经手人名称登录人所在部门所有人（默认当前登录人）长度不能超过255")
    @TableField(value = "applicant_name", condition = LIKE)
    @Excel(name = "经手人名称登录人所在部门所有人（默认当前登录人）")
    private String applicantName;

    /**
     * 系统code
     */
    @ApiModelProperty(value = "系统code")
    @Size(max = 20, message = "系统code长度不能超过20")
    @TableField(value = "system_code", condition = LIKE)
    @Excel(name = "系统code")
    private String systemCode;

    /**
     * 发票申请id
     */
    @ApiModelProperty(value = "发票申请id")
    @TableField(value = "invoice_apply_id")
    @Excel(name = "发票申请id")
    private Long invoiceApplyId;

    /**
     * 是否冲红
     */
    @ApiModelProperty(value = "是否冲红")
    @TableField(value = "is_flush_red")
    @Excel(name = "是否冲红")
    private Integer isFlushRed;

    /**
     * 原发票代码
     */
    @ApiModelProperty(value = "原发票代码")
    @TableField(value = "source_invoice_code")
    @Excel(name = "原发票代码")
    private String sourceInvoiceCode;
    /**
     * 发票号码
     */
    @ApiModelProperty(value = "原发票号码")
    @TableField(value = "source_invoice_num")
    @Excel(name = "原发票号码")
    private String sourceInvoiceNum;

    /**
     * 电子发票链接
     */
    @ApiModelProperty(value = "电子发票链接")
    @TableField(value = "invoice_link")
    @Excel(name = "原发票号码")
    private String invoiceLink;


    @Builder
    public Invoice(Long id, Long createdBy, LocalDateTime createTime, Long updatedBy, LocalDateTime updateTime,
                   Integer isEnabled, Integer isDeleted, Long projectId, Long subsystemId, Long tenantId,
                   Long businessId, InvoiceBusinessTypeEnum businessType, String invoiceType, String invoiceCode, String invoiceNum, BigDecimal invoiceAmount,
                   LocalDateTime invoicingTime, String invoiceState, String costType, Long applicantId, String applicantName, String systemCode, Long invoiceApplyId, Integer isFlushRed, String sourceInvoiceCode, String sourceInvoiceNum, String invoiceLink) {
        this.id = id;
        this.createdBy = createdBy;
        this.createTime = createTime;
        this.updatedBy = updatedBy;
        this.updateTime = updateTime;
        this.isEnabled = isEnabled;
        this.isDeleted = isDeleted;
        this.projectId = projectId;
        this.subsystemId = subsystemId;
        this.tenantId = tenantId;
        this.businessId = businessId;
        this.businessType = businessType;
        this.invoiceType = invoiceType;
        this.invoiceCode = invoiceCode;
        this.invoiceNum = invoiceNum;
        this.invoiceAmount = invoiceAmount;
        this.invoicingTime = invoicingTime;
        this.invoiceState = invoiceState;
        this.costType = costType;
        this.applicantId = applicantId;
        this.applicantName = applicantName;
        this.systemCode = systemCode;
        this.invoiceApplyId = invoiceApplyId;
        this.isFlushRed = isFlushRed;
        this.sourceInvoiceCode = sourceInvoiceCode;
        this.sourceInvoiceNum = sourceInvoiceNum;
        this.invoiceLink = invoiceLink;
    }

}
